<?php
class EmployeInfoControl extends CI_Controller{
	public function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
		$this->load->model('employe_info_model');
		$this->load->database();
		$this->load->library('session');
	}

	function index(){
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/employeInfoControl/index/';
		$config['total_rows'] = $this->db->count_all('employe_info');
		$config['per_page'] = '7';
		$config['full_tag_open'] = '<p>';
		$config['full_tag_close'] = '</p>';

		$this->pagination->initialize($config);
		$this->load->model('employe_info_model');
		$data['query'] = $this->employe_info_model->getEmployeInfo($config['per_page'],$this->uri->segment(3));
		//		$this->load->library('table');
		//		$this->table->set_heading('id', 'username','employna','email');
		$this->load->view('admin/employeeInfo/employee_index', $data);
		//		if( ! $this->session->userdata('login_s'))
		//		{
		//			redirect('welcome/index','refresh');
		//		}
		//		$data['query']=$this->employe_info_model->getAllEmployeInfo();
		//		$this->load->view('admin/employeeInfo/employee_index',$data);
	}

	function add(){
		$this->load->view('admin/employeeInfo/employee_add');
	}

	function doAdd(){
		$employeid = $this->employe_info_model->addEmployeInfo();
		$sess_data = array(
			'login_s' => True
		);
		$this->session->set_userdata($sess_data);
		redirect('employeInfoControl/index/','refresh');
	}

	function update(){
		$employeid = $this->uri->segment(3);
		$data['query']=$this->employe_info_model->getEmployeInfoById($employeid);
		$this->load->view('admin/employeeInfo/employee_edit',$data);
	}

	function doUpdate(){
		$msg="";
		$data=array(
				'employeid'=>$_POST['employeid'],
				'username'=>$_POST['username'], 
				'password'=>$_POST['password'],
				'employena'=>$_POST['employena'],
				'email'=>$_POST['email'],
		);
		$employeid = $this->employe_info_model->updateEmployeInfo($_POST['employeid'],$data);
		redirect('employeInfoControl/index/','refresh');
	}

	function delete(){
		$employeid = $this->uri->segment(3);
		$this->employe_info_model->delEmployeInfoById($employeid);
		redirect('employeInfoControl/index/','refresh');
			
	}
	//	function login_out(){
	//		$this->session->sess_destroy();
	//		redirect('blog/','refresh');
	//	}
}
?>